package it.poli.IA.representation;

import java.awt.Point;
public class Position implements Cloneable {
	private int x;
	private int y;
	public Position(int x, int y) {
		this.x = x;
		this.y = y;
	}
	public int getY() {
		return y;
	}
	
	public Position increaseXY(Position p)
	{
		if(p==null)
			return null;
		this.increaseX(p.getX());
		this.increaseY(p.getY());
		return this;
	}
	
	public Position getIncreasedXY(Position deltaXY) {
		if (deltaXY== null)
			return this;
		return new Position(this.x + deltaXY.getX(), this.y + deltaXY.getY());
	}
	
	private void increaseX(int increment)
	{
		this.x = x+increment;
	}
	private void increaseY(int increment)
	{
		this.y = y+ increment;
	}
	
	public void setY(int y) {
		this.y = y;
	}
	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public double distance(Position p2) 
	{
				Point pb = new Point(p2.getX(), p2.getY());
				Point pa = new Point(this.getX(), this.getY());
				return Math.sqrt( pb.distanceSq(pa));
				
	}

}
